﻿using System;

namespace School
{
    public class Student
    {
        private string name;
        private int uniqueNumber;

        public Student(string name, int number)
        {
            this.Name = name;
            this.UniqueNumber = number;
        }

        public string Name
        {
            get
            {
                return name;
            }
            private set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("The name can not be null.");
                }
                if (value == string.Empty)
                {
                    throw new ArgumentException("The name can not be empty.");
                }
                name = value;
            }
        }

        public int UniqueNumber
        {
            get
            {
                return uniqueNumber;
            }
            private set
            {
                if (value < 10000 || value > 99999)
                {
                    throw new ArgumentException("The uniqueNumber numst be in the range 10000 to 99999.");
                }
                uniqueNumber = value;
            }
        }

        public override bool Equals(object obj)
        {
            Student otherStudent = obj as Student;

            if (otherStudent == null)
            {
                return false;
            }
            if (!otherStudent.uniqueNumber.Equals(this.uniqueNumber))
            {
                return false;
            }

            return true;
        }
    }
}
